package com.cloudcc.mobile.parser;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.cloudcc.mobile.entity.FollowerUser;
import com.cloudcc.mobile.entity.GetFollowerUserMessage;
import com.cloudcc.mobile.util.Json;
import com.cloudcc.mobile.util.Tools;

public class GetFollowerUserParser {
	public static GetFollowerUserMessage getfollowers(String jsonstring) {
		ArrayList<FollowerUser> list = new ArrayList<FollowerUser>();
		GetFollowerUserMessage msg = new GetFollowerUserMessage();
		try {
			JSONObject obj = new JSONObject(jsonstring);
			msg.setResult(obj.getBoolean("result"));
			msg.setReturnInfo(obj.getString("returnInfo"));
			msg.setReturnCode(obj.getString("returnCode"));
			JSONArray json = obj.getJSONArray("data");
			for (int i = 0; i < json.length(); i++) {
				JSONObject jsonObj = json.getJSONObject(i);
				FollowerUser followerUser = (FollowerUser) Json.toObject(
						jsonObj.toString(), FollowerUser.class);
				list.add(followerUser);
			}
			msg.setList(list);
		} catch (Exception e) {
			Tools.handle(e);
		}
		return msg;
	}
}
